<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
</head>
<body>
    <pre>
        数组中第 K 大的元素
        提交链接： https://jinshuju.net/f/IQnNT9 
    </pre>
    <script>
        function sortK(arr, k) {
            let newArr = arr.slice(0).sort(function(a,b){ return a-b})
            let set = new Set()
            newArr.forEach((item) =>{
                set.add(item)
            })
            newArr = Array.from(set)
            return newArr[k-1] || '没有找到'
        }
        var arr1 = [2,12,5,4,8,9,11,2,4,3]
        alert(sortK(arr1, 6))
    </script>
</body>
</html>